curvetexture-sprite.effect 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. CCEffect %{
  2. techniques:
  3. - passes:
  4. - vert: sprite-vs:vert
  5. frag: sprite-fs:frag
  6. depthStencilState:
  7. depthTest: false
  8. depthWrite: false
  9. blendState:
  10. targets:
  11. - blend: true
  12. blendSrc: src_alpha
  13. blendDst: one_minus_src_alpha
  14. blendDstAlpha: one_minus_src_alpha
  15. properties: &props
  16. mainTexture: { value: white }
  17. altlasUV: { value: [0, 0, 0, 0] }
  18. # mainColor: { value: [1, 1, 1, 1], linear: true, editor: { type: color } }
  19. # colorScale: { value: [1, 1, 1], target: colorScaleAndCutoff.xyz }
  20. # alphaThreshold: { value: 0.5}
  21. # uMin: { value: 0.0}
  22. # uMax: { value: 1.0}
  23. # migrations: &migs
  24. # properties:
  25. # mainColor: { formerlySerializedAs: color }
  26. %}
  27. CCProgram sprite-vs %{
  28. precision highp float;
  29. #include <legacy/input>
  30. #include <builtin/uniforms/cc-global>
  31. // #include <legacy/decode-base>
  32. #include <legacy/local-batch>
  33. //显示声明layout(std140)
  34. uniform PARAMS_VERT {
  35. float placehold;
  36. };
  37. out vec2 v_uv;
  38. out vec3 fragWorldPos;
  39. vec4 vert () {
  40. vec4 position;
  41. CCVertInput(position);
  42. fragWorldPos = a_position;
  43. mat4 matWorld;
  44. CCGetWorldMatrix(matWorld);
  45. v_uv = a_texCoord;
  46. return cc_matProj * (cc_matView * matWorld) * position;
  47. }
  48. }%
  49. CCProgram sprite-fs %{
  50. precision highp float;
  51. in vec2 v_uv;
  52. in vec3 fragWorldPos;
  53. uniform sampler2D mainTexture;
  54. //显示声明layout(std140)
  55. uniform PARAMS_FRAG {
  56. vec4 altlasUV;
  57. float palcehold;
  58. // float uMin;
  59. // float uMax;
  60. };
  61. vec4 frag () {
  62. vec2 uvOrigin = altlasUV.xy;
  63. vec2 uvSize = altlasUV.zw;
  64. vec2 uvTmp = v_uv;
  65. uvTmp.y = 1.0 - uvTmp.y;
  66. vec2 mapUV = uvOrigin + uvTmp * uvSize;
  67. vec4 texColor = texture(mainTexture, mapUV);
  68. return texColor;
  69. }
  70. }%